<?php

namespace Module;

abstract class BaseModule {
    
    public function showTemplate($functionName, $args = array(), $layout = 'layout.php', $ext = ''){
        
        preg_match('/\\\([a-z]+)Module/i', get_class($this), $matches);
        
        $controller = $matches[1];
        $action = str_replace('Action', '', $functionName);
        foreach ($args as $key => $value){
            \Lib\Registry::get('view')->assign($key, $value);
        }
        
        \Lib\Registry::get('view')->setLayout($layout);
        $path = $controller. '/' . $action . $ext . '.php';
        return \Lib\Registry::get('view')->display($path);
    }

    public function pageNotFound(){
        
        return \Lib\Registry::get('view')->renderModule('/utils/pageNotFound');
    }
}

?>
